/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sucursal;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;

/**
 *
 * @author Nelly
 */
public class Xml {

    /**
     *
     */
    public void cargarConfiguracionSucursal() {
          try
          {
             SAXBuilder builder = new SAXBuilder(false);
             Document doc = builder.build("src/Configuracion.xml");
             Element raiz = doc.getRootElement();//Raiz mas general (configuracion
             if(raiz!=null)
             {
                 List nodos = raiz.getChildren("nodo");
                 Iterator nodo = nodos.iterator();
                 while (nodo.hasNext())
                 {
                    Element e = (Element) nodo.next();
                    Sucursal.setNombre(e.getChildText("nombre"));
                    Sucursal.setPortSalidaC(Integer.parseInt(e.getChildText("puertoServidor")));
                    Sucursal.setIpServidor(e.getChildText("ipServidor"));
                    Sucursal.setPortEscuchaC(Integer.parseInt(e.getChildText("puertoEscuchaC")));
                    Sucursal.setPortEscuchaH(Integer.parseInt(e.getChildText("puertoEscuchaH")));
                    Sucursal.setPortEscuchaA(Integer.parseInt(e.getChildText("puertoEscuchaA")));
                    Sucursal.setIpSucursal(e.getChildText("ipSucursal"));
                    System.out.println(Sucursal.getNombre());
                    System.out.println(String.valueOf(Sucursal.getIpServidor()));
                    System.out.println(String.valueOf(Sucursal.getPortEscuchaC()));
                    System.out.println(String.valueOf(Sucursal.getPortSalidaC()));
                 }
             }
          } catch (Exception e) {
             e.printStackTrace();
          }
     }

}
